//
//  main.cpp
//  评委打分.cpp
//
//  Created by 黄靖文 on 2018/6/6.
//  Copyright © 2018年 黄靖文. All rights reserved.
#include<iostream>
using namespace std;
double Average(int *a,int n)
{
    double sum=0.0;
    int min;
    int max;
    int count=0;
    double average;
    min=a[0];
    max=a[0];
    for(int i=0;i<n;i++)
    {
        if(a[i]<min)
            min=a[i];
        if(a[i]>max)
            max=a[i];
    }
    for(int j=0;j<n;j++)
    {
        if(a[j]==min)
        {
            a[j]=0;
            count++;
        }
        
        if(a[j]==max)
        {
            a[j]=0;
            count++;
        }
    }
    for(int k=0;k<n;k++)
    {
        sum+=a[k];
    }
    average=sum/(n-count);
    return average;
    
}
int main()
{
    double average;
    int a[]={1,3,2,4,6,5,8,7,9},n=9;
    average=Average(a,n);
    for(int i=0;i<n;i++)
    {
        printf("%d ",a[i]);
    }
    printf("\n");
    printf("%f",average);
    return 0;
    
}
